//
//  NSObject+DZCategory.m
//  Meidaojia
//
//  Created by Darren on 15/5/24.
//  Copyright (c) 2015年 Darren Zheng. All rights reserved.
//

#import "NSObject+DZCategory.h"

@implementation NSObject (DZCategory)

- (BOOL)dz_hasKey:(NSString *)strKey
{
    return [self respondsToSelector:NSSelectorFromString(strKey)];
}

- (void)dz_setValue:(id)value forKey:(NSString *)key
{
    if ([self dz_hasKey:key] && value && ![value isKindOfClass:[NSNull class]])
    {
        [self setValue:value forKey:key];
    }
}

- (id)dz_modelWithDictionary:(NSDictionary *)dict except:(NSArray *)array
{
    for (NSString *key in dict)
    {
        if (array)
        {
            if (![array containsObject:key])
            {
                [self dz_setValue:dict[key] forKey:key];
            }
        }
        else
        {
            [self dz_setValue:dict[key] forKey:key];
        }
    }
    return self;
}

@end
